package ext.acae2.object.ui;

import wt.util.WTException;
import wt.vc.wip.WorkInProgressHelper;
import wt.vc.wip.Workable;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;

/**
 * @desription rename action filter
 * @author cnie
 * @date 2013-7-29 上午11:13:16
 */
public class RenameHiddenFilter extends DefaultSimpleValidationFilter{

	@Override
	public UIValidationStatus preValidateAction(
			UIValidationKey uivalidationkey,
			UIValidationCriteria uivalidationcriteria) {
		UIValidationStatus status = UIValidationStatus.HIDDEN;
		Object obj = uivalidationcriteria.getContextObject().getObject();
		
		if(obj instanceof Workable){
			Workable workable = (Workable)obj;
			try {
				if(!WorkInProgressHelper.isCheckedOut(workable)){
					status = UIValidationStatus.ENABLED;
				}
			} catch (WTException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return status;
	}
	
	

}
